# coding=utf-8

def passwd(pd: str):
    item = 0
    az = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q',
          'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
    azup = {x.upper() for x in az}
    nums = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}
    special = {',', '.', '/', ';', '~', '@', '#', '$', '%', '^', '&', '*', '(', ')','!'}
    pd = set(pd)
    if len(pd & az) > 0:
        item += 1
    if len(pd & azup) > 0:
        item += 1
    if len(pd & nums) > 0:
        item += 1
    if len(pd & special) > 0:
        item += 1
    if item >= 3:
        return True
    else:
        return False


def zichuan(pd: str):
    item = []
    for i in range(len(pd) - 3):
        item.append(pd[i:i + 3])
    for j in item:
        if pd.count(j) > 1:
            return False
    return True


while True:
    try:
        a = input()
        if len(a) > 8:
            if passwd(a):
                if zichuan(a):
                    print('OK')
                else:
                    print('NG')
            else:
                print('NG')
        else:
            print('NG')
    except:
        break
